package com.example.lib_car

import android.graphics.Color
import android.widget.TextView
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class ParkingAdapter :BaseMultiItemQuickAdapter<ParkingEntity,BaseViewHolder> {
    constructor(){
        addItemType(1,R.layout.item_left)
        addItemType(2,R.layout.item_right)
    }

    override fun convert(holder: BaseViewHolder, item: ParkingEntity) {
        when(item.itemType){
            1 -> {
                holder.setText(R.id.parking_left,item.parkLeft.toString())
            }
            2 ->{
                if (item.parkUser==0L){
                    holder.getView<TextView>(R.id.parking_place).setBackgroundColor(Color.parseColor("#8CC152"))
                }else{
                    holder.getView<TextView>(R.id.parking_place).setBackgroundColor(Color.parseColor("#DEDEDE"))
                }
                holder.setText(R.id.parking_place,item.parkNum)
            }
        }
    }

}